package net.dgg.dggcloud.service.jrcrm.service.log;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import net.dgg.dggcloud.service.common.base.service.BaseService;
import net.dgg.dggcloud.service.jrcrm.dao.log.SysOpreateBusinessRecordDao;
import net.dgg.dggcloud.service.jrcrm.entity.business.Business;
import net.dgg.dggcloud.service.jrcrm.service.business.BusinessService;

/**
 * 操作商机记录Service
 * 
 * @Title: SysOpreateModuleRecordService
 * @Description:
 * @Auther: 雷力
 * @Date: 2018-11-09 14:51:50
 *
 */
@Service
public class SysOpreateBusinessRecordService extends BaseService implements SysRecordService {

	@Autowired
	private SysOpreateBusinessRecordDao dao;
	@Autowired
	private BusinessService businessService;

	/**
	 * 插入数据
	 * 
	 * @param record
	 */
	public void insert(Map<String, Object> map) {
		String[] businessIds = map.get("businessIds").toString().split(",");
		StringBuffer sb = new StringBuffer();
		for (String businessId : businessIds) {
			Business business = businessService.getBusinessById(Long.valueOf(businessId));
			sb.append(business.getNo() + ",");
		}
		map.put("businessNo", sb.deleteCharAt(sb.length() - 1));
		logger.error("=====>"+SysOpreateBusinessRecordService.class+"=====>插入数据...");
		dao.insert(map);
	}

	@SuppressWarnings("rawtypes")
	public List<Map> listOpreateBusinessRecordByMap(Map<String, Object> map) {
		return dao.listOpreateBusinessRecordByMap(map);
	}

	public Integer countOpreateBusinessRecordByMap(Map<String, Object> map) {
		return dao.countOpreateBusinessRecordByMap(map);
	}
}
